<?php
$this->pageTitle = 'Thông tin tài khoản [ ' . CHtml::encode($model->username). ' ]';
$this->breadcrumbs = array(
	'Ban quản trị' => array('index'),
	CHtml::encode($model->username) => array(),
	'Thông tin tài khoản',
);
$profile = $model->profile;
?>
<div class="heading">
    <h1><img src="<?php echo Util::themeUrl() ?>/images/header.ico" /><?php echo $this->pageTitle;?></h1>
    <div class="controls">
        <?php
        if (isset($_GET['ajax'])) {
            echo CHtml::button(UserModule::t('Update'), array('class' => 'controls', 'onclick' => "location.href='" . $this->createUrl('update', array('id' => $model->id, 'ajax' => true)) . "'"));
            echo CHtml::ajaxButton(UserModule::t('Delete'), array('delete', 'ajax' => true), array(
                'type' 		=> 'post',
                'data' 		=> "chk[]={$model->id}",
                'success' 	=> 'function(data){$(".controls").hide(); $(".content").html(data);}'
            ), array('class' => 'controls', 'confirm'=> UserModule::t('Are you sure you want to delete this item?')));
        } else {
            echo CHtml::link(UserModule::t('Update'), array('update', 'id' => $model->id), array('class' => 'controls'));
            echo CHtml::link(UserModule::t('Delete'), array('delete'), array(
                'class' => 'controls',
                'submit' => array('delete'),
                'confirm'=> UserModule::t('Are you sure you want to delete this item?'),
                'params' => array('chk[]' => $model->id),
                'ajax' => array('type' => 'post')
            ));
        }
     ?>
    </div>
</div>

<div class="content">
	<div class="user-profile">
		<div class="left-column full-width">
			<div id="businessCardView" class="sliding-panel business-card showing-panel">
					<div class="border-gravatar"><?php echo CHtml::image(Util::getImageExist("avatar", $profile->avatar), "avatar",  array("class" =>"gravatar"));?></div>
					<h2>
						<?php echo CHtml::image(Util::getImageExist("avatar", (($profile->sex == SEX_BOY) ? ICONBOY : ICONGIRL)), "avatar",  array('title' => (($profile->sex == SEX_BOY) ? TITLE_BOY : TITLE_GIRL)));?>
						<?php echo Util::formatFullName(CHtml::encode($profile->fullname));?>
					</h2>
					<?php $age = Util::getAge(CHtml::encode($profile->birthday));?>
					<sub><?php echo ($age != '') ? ('(' . $age . ' tuổi)') : null;?></sub>
					<div>
						<table>
							<tr>
								<td><?php echo CHtml::encode($profile->getAttributeLabel('listcourses'))?></td>
								<td><?php //echo CHtml::checkBoxList($profile,'listcourses',CHtml::listData(Courses::model()->findAllByAttributes(arra, 'id', 'name'), 
											//array('labelOptions' => array('style'=>'display:inline')));?>
									<?php
										$modeCourses = json_decode($profile->listcourses, true);
										$listCourses = Courses::model()->findAllByAttributes(array('id' => $modeCourses)); 
										$count_listcourse = count($listCourses);
										$i = 0;
										foreach ($listCourses as $listCourse) {
											$i++;
											$glue = $i < $count_listcourse ? "," : "";
											echo CHtml::encode($listCourse->name) . $glue;
										}
									?>		
								</td>
							</tr>
							<tr>
								<td><?php echo CHtml::encode($profile->getAttributeLabel('birthday'))?></td>
								<td><?php echo CHtml::encode($profile->birthday);?></td>
							</tr>
							<tr>
								<td><?php echo CHtml::encode($profile->getAttributeLabel('phone'))?></td>
								<td><?php echo Util::formatPhone(CHtml::encode($profile->phone));?></td>
							</tr>
							<tr>
								<td><?php echo CHtml::encode($profile->getAttributeLabel('cellphone'))?></td>
								<td><?php echo Util::formatPhone(CHtml::encode($profile->cellphone));?></td>
							</tr>
							<tr>
								<td><?php echo CHtml::encode($model->getAttributeLabel('email'))?></td>
								<td><?php echo CHtml::encode($model->email)?></td>
							</tr>
							<tr>
								<td><?php echo CHtml::encode($profile->getAttributeLabel('address'))?></td>
								<td><?php echo CHtml::encode($profile->address);?></td>
							</tr>
							<tr>
								<td><?php echo CHtml::encode($model->getAttributeLabel('status'))?></td>
								<td><?php echo Util::itemAlias('UserStatus', $model->status);?></td>
							</tr>
							<tr>
								<td><?php echo CHtml::encode($model->getAttributeLabel('create_at'))?></td>
								<td><?php echo Util::formatTime(CHtml::encode($model->create_at));?></td>
							</tr>
							<tr>
								<td><?php echo CHtml::encode($model->getAttributeLabel('lastvisit_at'))?></td>
								<td><?php echo Util::formatTime(CHtml::encode($model->lastvisit_at));?></td>
							</tr>
						</table>
					</div>
			</div>
		</div>
	</div>
</div>